import React, { Component } from 'react'

// 内部自动实现shouldComponentUpdate方法，但是只是进行浅层比较（只会比较第一层数据）
// export class Home extends PureComponent {
export class Home extends Component {
  constructor(props) {
    super(props)

    this.state = {
      friends: [],
    }
  }

  shouldComponentUpdate(nextProps, nextState) {
    if (
      this.props.message !== nextProps.message ||
      this.state.friends !== nextState.friends
    ) {
      return true
    }
    return false
  }

  render() {
    console.log('Home render')

    return (
      <div>
        <h2>Home Page{this.props.message}</h2>
      </div>
    )
  }
}

export default Home
